//
//  DDSingleton.h
//  音乐播放器
//
//  Created by 丁鼎 on 16/8/15.
//  Copyright © 2016年 丁鼎. All rights reserved.
//

#import <Foundation/Foundation.h>
/**
 *  定义单例模式类 INTERFACE__SINGLETON(类名)
 *  实现单例模式类 IMPLEMENTATION__SINGLETON(类名)
 */

#undef INTERFACE_SINGLETON
#define INTERFACE_SINGLETON(__class) \
   - (__class *)sharedInstance; \
   + (__class *)sharedInstance; \

#undef IMPLEMENTATION_SINGLETON 
#define IMPLEMENTATION_SINGLETON( __class ) \
   - (__class *)sharedInstance{ \
    return [__class  sharedInstance]; \
} \
   + (__class *)sharedInstance{ \
    static dispatch_once_t once; \
    static __class * __singleton__; \
    dispatch_once( &once, ^{ __singleton__ = [[[self class] alloc] init]; } ); \
    return __singleton__; \
}
